package edu.friday.common.security.service;

import edu.friday.model.SysMenu;
import edu.friday.model.SysUser;
import edu.friday.model.vo.SysUserVO;
import edu.friday.repository.ISysMenuRepository;
import edu.friday.service.ISysMenuService;
import edu.friday.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

@Service
public class SysPermissionService {

    @Autowired
    private ISysMenuService iSysMenuService;

    @Autowired
    private ISysRoleService iSysRoleService;

    public Set<String> selectMenuPermission(SysUserVO sysUserVO) {
//        if (sysUserVO.isAdmin()) {
//            Set<String> permission = new HashSet<>();
//            permission.add("*:*:*");
//            return permission;
//        }
        return iSysMenuService.selectMenuPermissionByUserId(sysUserVO.getUserId());
    }

    public Set<String> selectRolePermission(SysUserVO user) {
        return iSysRoleService.selectRolePermissionByUserId(user.getUserId());
    }
}
